package com.rongke.web;

import com.rongke.commons.JsonResp;
import com.rongke.mapper.ComplicationMapper;
import com.rongke.model.Complication;
import com.rongke.service.ComplicationService;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;

/**
 * @ComplicationController
 * @并发症Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/complication")
@Transactional
public class ComplicationController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private ComplicationService complicationService;

    /**
     * @添加并发症
     * @param complication
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public JsonResp addComplication(@RequestBody Complication complication){
        log.debug("添加并发症");
        complicationService.insert(complication);
        return JsonResp.ok(complication);
    }

    /**
     * @修改并发症
     * @param complication
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateComplication(@RequestBody Complication complication){
        log.debug("修改并发症");
        complicationService.updateById(complication);
        return JsonResp.ok(complication);
    }
    /**
     * @根据id查找并发症
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectComplication(Long id){
        log.debug("查找并发症");
        Complication complication = complicationService.selectById(id);
        return JsonResp.ok(complication);
    }


}
